package com.twu.biblioteca.user;

import com.twu.biblioteca.item.Item;
import com.twu.biblioteca.order.Order;

/**
 * Created by Enrico on 17/09/2014.
 */
public class User {

    private String name;
    private String email;
    private String phoneNo;
    private Order order;
    private Account account;

    public User(String name, String email, String phoneNo) {
        this.name = name;
        this.email = email;
        this.phoneNo = phoneNo;
        this.order = new Order();
        this.account = new Account();
    }

    public User(String libraryNo, String password, String name, String email, String phoneNo) {
        this.name = name;
        this.email = email;
        this.phoneNo = phoneNo;
        this.order = new Order();
        this.account = new Account(libraryNo, password);
    }

    public boolean matches(String libraryNo, String password) {
        return account.login(libraryNo, password);
    }

    public void add(Item item) {
        this.order.add(item);
    }

    public void remove(Item item) {
        this.order.remove(item);
    }

    public void showInfo() {
        System.out.println(toString());
    }

    public void sayHello() {
        System.out.println("Hello " + name + "!!!");
    }

    public boolean isEmpty(){
        return order.isEmpty();
    }

    @Override
    public String toString() {
        return "\tName: " + name + "\n" + "\tEmail: " + email + "\n" + "\tPhoneNo: " + phoneNo + "\n";
    }
}
